<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui" template="/template/template.xhtml"
	xmlns:s="http://sduept.security.el/func">
	<ui:define name="head">
		<link rel="stylesheet"
			href="/resources/plugins/datatables/dataTables.bootstrap.css" />
		<style>
</style>
	</ui:define>
	<ui:define name="content">
		<p:confirmDialog global="true" showEffect="fade" hideEffect="fade">
			<p:commandButton value="是" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
			<p:commandButton value="否" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
		</p:confirmDialog>
		<div class='full-center-content-scroll-noheader'>
			<h:form id="form">
				<p:growl id="msgs" showDetail="true" />
				<div class="box box-solid with-border">
					<div class="box-header">
						<h:outputText value="未维护变电站： " />
						<p:selectBooleanCheckbox value="#{waveRecorderConfigController.noSubtation}"
							style="margin-right:15px;">
							<p:ajax event="change" update="subtationNameText" />
						</p:selectBooleanCheckbox>
						<h:outputText value="未生成dmf： " />
						<p:selectBooleanCheckbox value="#{waveRecorderConfigController.noDmf}"
							style="margin-right:15px" />
						<h:outputText value="未生成cfg：" />
						<p:selectBooleanCheckbox value="#{waveRecorderConfigController.noCfg}"
							style="margin-right:30px" />
						<p:commandButton style="margin-left:10px;" icon="ui-icon-search" value="查询" update="table"
							actionListener="#{waveRecorderConfigController.query}" />
						<p:commandButton icon="ui-icon-refresh" value="重置" actionListener="#{waveRecorderConfigController.reset}" update="form" style="margin-left:5px;" />
						<div class="box-tools pull-right">
							<button  type="button" id="selectButton" title="高级查询" class="btn btn-default"
								onclick="onSelectDivClick();" style="margin-right: 50px;">
								<span id="selectButtonIcon" class="fa fa-caret-down">高级查询</span>
							</button>
						</div>
					</div>
					<div class="panel-collapse collapse" id="selectDiv">
						<h:outputText value="所属变电站：" style="margin-left:10px"/>
						<p:inputText id="subtationNameText" value="#{waveRecorderConfigController.subtationName}"
							disabled="#{waveRecorderConfigController.noSubtation == true}" />
						<h:outputText value="设备名称：" style="margin-left:10px;" />
						<p:inputText value="#{waveRecorderConfigController.equipmentName}" />
					</div>
				</div>
				<p:toolbar id="toolbar">
					<f:facet name="left">
						<p:commandButton value="新增录波设备" update="createForm:createDlg" icon="ui-icon-plus"
							actionListener="#{waveRecorderConfigController.preCreate}"
							oncomplete="PF('createDlg').show()"
							rendered="#{s:hasPermission(session,'jcsj_sjwh_ecsbwh_lbsbwh_xz')}" />
						<p:commandButton value="编辑" update="createForm:createDlg msgs" icon="ui-icon-pencil"
							oncomplete="PF('createDlg').show()" actionListener="#{waveRecorderConfigController.preEdit}"
							disabled="#{waveRecorderConfigController.selected == null}"
							rendered="#{s:hasPermission(session,'jcsj_sjwh_ecsbwh_lbsbwh_bj')}" />
						<p:commandButton value="删除" icon="ui-icon-trash" update="table toolbar msgs"
							actionListener="#{waveRecorderConfigController.delete}"
							disabled="#{waveRecorderConfigController.selected == null}"
							rendered="#{s:hasPermission(session,'jcsj_sjwh_ecsbwh_lbsbwh_sc')}">
							<p:confirm header="提示" message="确定删除该记录吗?" icon="ui-icon-alert" />
						</p:commandButton>
					</f:facet>
				</p:toolbar>
				<p:dataTable id="table" var="item" selection="#{waveRecorderConfigController.selected}"
					value="#{waveRecorderConfigController.model}" rowIndexVar="ite"
					lazy="true" rowKey="#{item.id}" style="margin-bottom:0;text-align:center" emptyMessage="无记录" rows="20" paginator="true"
					paginatorTemplate="{Customization} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
					rowsPerPageTemplate="20,50,100" paginatorPosition="bottom">
					<f:facet name="{Customization}">
						<p:outputLabel value="总计：#{waveRecorderConfigController.rowCount} 条记录"
							style="margin-right:20px;" />
					</f:facet>
					<p:ajax event="rowSelectRadio" update="form:toolbar" />
					<p:column selectionMode="single" style="text-align:center;width:10px" />
					<p:column style="width:20px" headerText="序号 ">
						<h:outputText value="#{ite+1}" />
					</p:column>
					<p:column width="60" headerText="设备名称">
						<h:outputText value="#{item.name}" />
					</p:column>
					<p:column width="60" headerText="所属变电站">
						<h:outputText value="#{item.subName}" />
					</p:column>
					<p:column width="60" headerText="设备厂家">
						<h:outputText value="#{item.devManufacturer}" />
					</p:column>
					<p:column width="60" headerText="设备型号">
						<h:outputText value="#{item.devType}" />
					</p:column>
					<p:column width="40">
						<p:commandLink update="dialogForm:dmfInfoDialog" oncomplete="PF('dmfInfoDialog').show()"
							disabled="#{item.dmf == null}"
							actionListener="#{waveRecorderConfigController.setSelected(item)}">
							<h:outputText value="dmf文件" style="text-decoration:underline;color:red;" />
						</p:commandLink>
						<p:commandLink oncomplete="PF('cfgInfoDialog').show()" update="dialogForm:cfgInfoDialog"
							disabled="#{item.cfg == null}"
							actionListener="#{waveRecorderConfigController.setSelected(item)}">
							<h:outputText value="cfg文件" style="margin-left:40px;text-decoration:underline;color:red;" />
						</p:commandLink>
					</p:column>
				</p:dataTable>
			</h:form>
			<h:form id="dialogForm">
				<p:dialog id="dmfInfoDialog" header="dmf文件" widgetVar="dmfInfoDialog" height="600px"
					width="1100px" modal="true">
					<p:panel style="white-space:pre-wrap;">
												#{waveRecorderConfigController.selected.dmf}
					</p:panel>
				</p:dialog>
				<p:dialog id="cfgInfoDialog" header="cfg文件" widgetVar="cfgInfoDialog" height="600px"
					width="1100px" modal="true">
					<p:panel style="white-space:pre-wrap;">
												#{waveRecorderConfigController.selected.cfg}
					</p:panel>
				</p:dialog>
			</h:form>
			<h:form id="createForm">
				<p:dialog id="createDlg" widgetVar="createDlg"
					header="#{waveRecorderConfigController.created.id == null?'新建':'编辑'}" modal="true" width="600"
					height="300">
					<p:toolbar>
						<f:facet name="left">
							<p:commandButton value="保存" update="form:table form:msgs" icon="ui-icon-disk"
								oncomplete="PF('createDlg').hide()" actionListener="#{waveRecorderConfigController.save}" />
						</f:facet>
					</p:toolbar>
					<p:outputPanel style="width:100%;">
						<p:panelGrid style="width:100%;" rendered="#{not empty waveRecorderConfigController.created}">
							<p:row>
								<p:column>
									<p:outputLabel value="设备名称" />
								</p:column>
								<p:column>
									<p:inputText style="width:100%;" value="#{waveRecorderConfigController.created.name}" />
								</p:column>
							</p:row>
							<p:row>
								<p:column>
									<p:outputLabel value="所属变电站" />
								</p:column>
								<p:column>
									<!-- <p:autoComplete forceSelection="false" scrollHeight="450" dropdown="true"
										value="#{waveRecorderConfigController.created.subName}"
										completeMethod="#{waveRecorderConfigController.completeWorkplace}">
									</p:autoComplete> -->
									<p:inputText id="equipment_text"
										value="#{waveRecorderConfigController.created.subName}" required="true"
										requiredMessage="设备为必填项" style="width:75%" />
									<p:commandButton value="选择变电站" process="@this" style="margin-left:5px;"
										actionListener="#{waveRecorderConfigController.getEquipmentByStation()}">
										<p:ajax event="dialogReturn"
											listener="#{waveRecorderConfigController.onSelectorChosenSubstation}"
											update="equipment_text form:msgs" />
									</p:commandButton>
								</p:column>
							</p:row>
							<p:row>
								<p:column>
									<p:outputLabel value="设备厂家" />
								</p:column>
								<p:column>
									<p:inputText style="width:100%;"
										value="#{waveRecorderConfigController.created.devManufacturer}" />
								</p:column>
							</p:row>
							<p:row>
								<p:column>
									<p:outputLabel value="设备型号" />
								</p:column>
								<p:column>
									<p:inputText style="width:100%;" value="#{waveRecorderConfigController.created.devType}" />
								</p:column>
							</p:row>
						</p:panelGrid>
					</p:outputPanel>
				</p:dialog>
			</h:form>
		</div>
	</ui:define>
	<ui:define name="contentend">
		<script src="/resources/plugins/datatables/jquery.dataTables.js"></script>
		<script
			src="/resources/plugins/datatables/dataTables.bootstrap.min.js"></script>
		<script src="/resources/js/tables/mytable.js"></script>
		<script>
			function onSelectDivClick() {
				var div = $('#selectDiv');
				if (div.hasClass('in')) {
					div.collapse('hide');
					$('#selectButtonIcon').removeClass("fa fa-caret-up");
					$('#selectButtonIcon').addClass("fa fa-caret-down");
				} else {
					div.collapse('show');
					$('#selectButtonIcon').removeClass("fa fa-caret-down");
					$('#selectButtonIcon').addClass("fa fa-caret-up");
				}
			}
		</script>
	</ui:define>
</ui:composition>
